<?php
defined('BASEPATH') OR exit('No direct script access allowed');

include_once 'adminBase.php';

class Admin extends AdminBase{
    
    public function login(){
        
        $user       = $this->input->post('user',true);
        $password   = $this->input->post('password');
        if($user && $password){
            $password   = md5_password($password);
            $user_info  = $this->db->query("select id,user from admin where user='{$user}' and password = '{$password}'")->result_array();
            if(!empty($user_info))
            {
                $this->session->set_userdata(['user_info'=>$user_info[0]]);
                jump('/admin/index');                
            }else{
                $this->load->vars('error',"1");
            }
        }
        $this->load->vars('title','登录');
        $this->load->view('login/login.php');
    }
    
    public function logout(){
        $this->session->sess_destroy();
        jump('/admin/login');
    }
    
    public function index(){
        $this->load->vars('title','后台首页');
        $this->load->vars('description','工作台');
        $this->load->vars('load_tempalte','admin/aa.php');
        $this->load->view('public/layout.php');
    }
   
}